#include "util_cmd.h"
#include "stdio.h"

void addCmd(void);
void addParam(void);
void deleteCmd(void);
void deleteParam(void);
void helpCallBack(CmdParamTypeDef *param);

static void cmd1Callback(CmdParamTypeDef *param);
static void cmd2Callback(CmdParamTypeDef *param);
static void cmd3Callback(CmdParamTypeDef *param);
static void cmd4Callback(CmdParamTypeDef *param);
static void cmd5Callback(CmdParamTypeDef *param);
static void cmd6Callback(CmdParamTypeDef *param);
static void cmd7Callback(CmdParamTypeDef *param);
static void cmd8Callback(CmdParamTypeDef *param);
static void cmd8Callback(CmdParamTypeDef *param);
static void cmd9Callback(CmdParamTypeDef *param);
static void cmd10Callback(CmdParamTypeDef *param);
static void cmd11Callback(CmdParamTypeDef *param);
static void cmd12Callback(CmdParamTypeDef *param);
static void cmd13Callback(CmdParamTypeDef *param);
static void cmd14Callback(CmdParamTypeDef *param);
static void cmd15Callback(CmdParamTypeDef *param);
static void cmd16Callback(CmdParamTypeDef *param);
static void cmd17Callback(CmdParamTypeDef *param);

int main(int argc, char *argv[])
{
    CmdInit();
    addCmd();
    addParam();

    CmdShow();

    printf("\n");
    CmdCheck("help -param");
    CmdCheck("cmd2 2dmc");
    CmdCheck("cmd3 -param2");

    deleteCmd();
    deleteParam();
    CmdShow();

    return 0;
}

void addCmd(void)
{
    CmdAppend("help", helpCallBack);
    CmdAppend("cmd1", cmd1Callback);
    CmdAppend("cmd2", cmd2Callback);
    CmdAppend("cmd3", cmd3Callback);
    CmdAppend("cmd4", cmd4Callback);
    CmdAppend("cmd5", cmd5Callback);
    CmdAppend("cmd6", cmd6Callback);
    CmdAppend("cmd7", cmd7Callback);
    CmdAppend("cmd8", cmd8Callback);
    CmdAppend("cmd9", cmd9Callback);
    CmdAppend("cmd10", cmd10Callback);
    CmdAppend("cmd11", cmd11Callback);
    CmdAppend("cmd12", cmd12Callback);
    CmdAppend("cmd13", cmd13Callback);
    CmdAppend("cmd14", cmd14Callback);
    CmdAppend("cmd15", cmd15Callback);
    CmdAppend("cmd16", cmd16Callback);
    CmdAppend("cmd17", cmd17Callback);
}

void addParam(void)
{
    CmdAppendParam("help", "param1");
    CmdAppendParam("help", "param2");
    CmdAppendParam("help", "param3");
    CmdAppendParam("help", "param4");
    CmdAppendParam("help", "param5");
    CmdAppendParam("help", "param6");
    CmdAppendParam("help", "param7");
    CmdAppendParam("help", "param8");
    CmdAppendParam("help", "param9");
    CmdAppendParam("help", "param10");
    CmdAppendParam("help", "param11");
    CmdAppendParam("help", "param12");
    CmdAppendParam("help", "param13");
    CmdAppendParam("help", "param14");
    CmdAppendParam("help", "param15");
    CmdAppendParam("help", "param16");
    CmdAppendParam("help", "param17");

    CmdAppendParam("cmd1", "param1");

    CmdAppendParam("cmd3", "param1");
    CmdAppendParam("cmd3", "param2");

    CmdAppendParam("cmd15", "param1");
    CmdAppendParam("cmd15", "param2");
}

void deleteCmd(void)
{
    CmdDelete("cmd17");
}

void deleteParam(void)
{
    CmdDeleteParam("help", "param16");
}

void helpCallBack(CmdParamTypeDef *param)
{
    printf("On helpCallBack\n");
    if (param != NULL) {
        printf("param is %s\n", param->name);
    }
}

static void cmd1Callback(CmdParamTypeDef *param)
{
    printf("On cmd1Callback\n");
}

static void cmd2Callback(CmdParamTypeDef *param)
{
    printf("On cmd2Callback\n");
}

static void cmd3Callback(CmdParamTypeDef *param)
{
    printf("On cmd3Callback\n");
    if (param != NULL) {
        printf("param is %s\n", param->name);
    }
}

static void cmd4Callback(CmdParamTypeDef *param)
{
    printf("On cmd4Callback\n");
}

static void cmd5Callback(CmdParamTypeDef *param)
{
    printf("On cmd5Callback\n");
}

static void cmd6Callback(CmdParamTypeDef *param)
{
    printf("On cmd6Callback\n");
}

static void cmd7Callback(CmdParamTypeDef *param)
{
    printf("On cmd7Callback\n");
}

static void cmd8Callback(CmdParamTypeDef *param)
{
    printf("On cmd8Callback\n");
}

static void cmd9Callback(CmdParamTypeDef *param)
{
    printf("On cmd9Callback\n");
}

static void cmd10Callback(CmdParamTypeDef *param)
{
    printf("On cmd10Callback\n");
}

static void cmd11Callback(CmdParamTypeDef *param)
{
    printf("On cmd11Callback\n");
}

static void cmd12Callback(CmdParamTypeDef *param)
{
    printf("On cmd12Callback\n");
}

static void cmd13Callback(CmdParamTypeDef *param)
{
    printf("On cmd13Callback\n");
}

static void cmd14Callback(CmdParamTypeDef *param)
{
    printf("On cmd14Callback\n");
}

static void cmd15Callback(CmdParamTypeDef *param)
{
    printf("On cmd15Callback\n");
}

static void cmd16Callback(CmdParamTypeDef *param)
{
    printf("On cmd16Callback\n");
}

static void cmd17Callback(CmdParamTypeDef *param)
{
    printf("On cmd17Callback\n");
}
